<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户优惠券列表')" />
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <!--<li>-->
                                <!--<label>用户：</label>-->
                                <!--<select name="memberId" class="form-control m-b">-->
                                    <!--<option value="">所有</option>-->
                                    <!--<option th:each="dict : ${memberList}" th:text="${dict.username}+'-'+${dict.frameNo}" th:value="${dict.id}"></option>-->
                                <!--</select>-->
                            <!--</li>-->
                            <li>
                                <label>状态：</label>
                                <select name="status" th:with="type=${@dict.getType('user_coupon_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>类型：</label>
                                <select name="type" th:with="type=${@dict.getType('coupon_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
<!--                            <li class="select-time">-->
<!--                                <label>创建时间： </label>-->
<!--                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="btime"/>-->
<!--                                <span>-</span>-->
<!--                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="etime"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system/coupon:usercoupon:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js"/>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system/coupon:usercoupon:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system/coupon:usercoupon:remove')}]];
        var prefix = ctx + "system/coupon/usercoupon";
        var typeDatas = [[${@dict.getType('coupon_type')}]];
        var statusDatas = [[${@dict.getType('user_coupon_status')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户优惠券",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'memberId',
                    title: '用户主键ID'
                },
                {
                    field: 'couponId',
                    title: '优惠券主键ID'
                },
                {
                    field: 'name',
                    title: '优惠券名称'
                },
                {
                    field: 'status', 
                    title: '状态',
                    formatter: function(value, row, index)  {
                        if (value == 0) {
                            return "未使用";
                        }
                        if (value == 1) {
                            return "已使用";
                        }
                        if (value == 2) {
                            return "已过期";
                        }
                        if (value == 3) {
                            return "已失效";
                        }
                    }
                },
                {
                    field: 'type', 
                    title: '类型',
                    formatter: function(value, row, index)  {
                        if (value == 0) {
                            return "满减券";
                        }
                        if (value == 1) {
                            return "抵扣券";
                        }
                    }
                },
                {
                    field: 'useCondition', 
                    title: '使用条件'
                },
                {
                    field: 'price', 
                    title: '优惠金额'
                },
                {
                    field: 'enoughMoney',
                    title: '满减满足金额'
                },
                {
                    field: 'startTime', 
                    title: '开始时间'
                },
                {
                    field: 'endTime', 
                    title: '结束时间'
                },
                {
                    field: 'notes', 
                    title: '补充说明'
                },
                {
                    field: 'created',
                    title: '领取时间'
                },
                {
                    field: 'usedTime',
                    title: '使用时间'
                },]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>